<?php
/**
 * Created by PhpStorm.
 * User: VJLau
 * Date: 2018/2/5
 * Time: 下午12:29
 */
$uniacid = $_W['uniacid'];

// 目的地
$dests = pdo_fetchall("SELECT * FROM " . tablename('bontrip_dest') .
    " WHERE is_index = 1 AND uniacid= '{$uniacid}' AND deleted_at is null ORDER BY sort ASC,id DESC");
//处理目的地数据，每三个为一组
$num = ceil(count($dests)/3);
$dests_list = array();
for($i = 0; $i < $num;$i++){
    for ($j = 0;$j < 3;$j++){
        if(!empty($dests[$j+$i*3])){
            $dests_list[$i][] = $dests[$j+$i*3];
        }else{
            $dests_list[$i][] = null;
        }
    }
}
// 单品
$singles = pdo_fetchall("SELECT sg.*,currency.exchange_rate FROM " . tablename('bontrip_single')
    . " AS sg LEFT JOIN ".tablename('bontrip_currency')." AS currency ON currency.id = sg.currency_id WHERE sg.is_index = 1 AND sg.uniacid = '{$uniacid}' AND sg.deleted_at is null ORDER BY sg.sort ASC,sg.id DESC");

//一日游
$onedays = pdo_fetchall("SELECT od.*,currency.exchange_rate FROM " . tablename('bontrip_oneday')
    . " AS od LEFT JOIN ".tablename('bontrip_currency')." AS currency ON currency.id = od.currency_id WHERE od.is_index = 1 AND od.uniacid = '{$uniacid}' AND od.deleted_at is null ORDER BY od.sort ASC,od.id DESC");

//精品游
$qualitys = pdo_fetchall("SELECT ql.*,currency.exchange_rate FROM " . tablename('bontrip_quality')
    . " AS ql LEFT JOIN ".tablename('bontrip_currency')." AS currency ON currency.id = ql.currency_id WHERE ql.is_index = 1 AND ql.uniacid = '{$uniacid}' AND ql.deleted_at is null ORDER BY ql.sort ASC,ql.id DESC");


$title = "知行";
include $this->template('index');